/**
 * jims
 */
package com.jims.master.modules.orders.web;

import com.google.common.collect.Lists;
import com.jims.master.common.data.StringData;
import com.jims.master.common.persistence.Page;
import com.jims.master.common.utils.StringUtils;
import com.jims.master.common.web.BaseController;
import com.jims.master.common.web.impl.BaseDto;
import com.jims.master.modules.doctor.entity.PatVisit;
import com.jims.master.modules.doctor.service.PatVisitService;
import com.jims.master.modules.drug.entity.DrugStorageDept;
import com.jims.master.modules.drug.service.DrugStorageDeptService;
import com.jims.master.modules.finance.entity.InpBillDetail;
import com.jims.master.modules.finance.service.InpBillDetailService;
import com.jims.master.modules.orders.entity.DrugDispRec;
import com.jims.master.modules.orders.entity.Orders;
import com.jims.master.modules.orders.service.DrugDispMidService;
import com.jims.master.modules.orders.service.DrugDispRecService;
import com.jims.master.modules.orders.service.OrdersService;
import com.jims.master.modules.orders.vo.CountDrug;
import com.jims.master.modules.orders.vo.OrdersConf;
import com.jims.master.modules.sys.entity.OrgDept;
import com.jims.master.modules.sys.service.OrgDeptService;
import com.jims.master.modules.sys.utils.UserUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 遗嘱Controller
 *
 * @author 陈晓阳
 * @version 2017-03-27
 */
@Controller
@RequestMapping(value = "${adminPath}/orders/orders")
public class OrdersController extends BaseController {

    @Autowired
    private OrdersService ordersService;

    @Autowired
    private PatVisitService patVisitService;
    @Autowired
    private DrugStorageDeptService drugStorageDeptService;

    @Autowired
    private DrugDispMidService drugDispMidService;

    @Autowired
    private DrugDispRecService drugDispRecService;

    @Autowired
    private InpBillDetailService inpBillDetailService;

    @Autowired
    private OrgDeptService orgDeptService;

    @ModelAttribute
    public Orders get(@RequestParam(required = false) String id) {
        Orders entity = null;
        if (StringUtils.isNotBlank(id)) {
            entity = ordersService.get(id);
        }
        if (entity == null) {
            entity = new Orders();
        }
        return entity;
    }

    /**
     * 跳转遗嘱首页面
     *
     * @param orders----patientId 与 visitId
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"index", ""})
    public String list(Orders orders, HttpServletRequest request, HttpServletResponse response, Model model) {
        UserUtils userUtils = new UserUtils();
        model.addAttribute("creator",userUtils.getUser().getId());
        model.addAttribute("billingDept",userUtils.getUser().getOrgDept().getId());
        Page<Orders> page = ordersService.findPage(new Page<Orders>(request, response), orders);
        model.addAttribute("ordersPage", page);
        model.addAttribute("orders", orders);
        return "modules/orders/ordersIndex";
    }

    /**
     * 右侧新增遗嘱页面
     *
     * @param orders ---patientId与visitId
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = "form")
    public String form(Orders orders, Model model) {
        OrdersConf ordersConf= new OrdersConf();
        if(orders.getParent()!=null&&StringUtils.isNotBlank(orders.getParent().getId())){
            Orders porders=ordersService.get(orders.getParent().getId());
            if ("A".equalsIgnoreCase(porders.getOrderClass())) {
                ordersConf.setCategory("0");
            } else {
                if (StringUtils.isBlank(porders.getOrderClass())) {
                    ordersConf.setCategory("2");
                }else{
                    ordersConf.setCategory("1");
                }
            }
            ordersConf.setContinue1(porders.getRepeatIncaditor());
            ordersConf.setValuation(porders.getBillingAttr());
        }else{
            ordersConf.setCategory(orders.getIsDrug());
            ordersConf.setContinue1(orders.getRepeatIncaditor());
            ordersConf.setValuation(orders.getBillingAttr());
        }
        model.addAttribute("ordersConf",ordersConf);
        model.addAttribute("orders", orders);
        return "modules/orders/ordersForm";
    }

    /**
     * 修改医嘱
     * @param orders
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = "updateForm")
    public String updateForm(Orders orders, Model model,HttpServletRequest httpServletRequest,HttpServletResponse response) {
        OrdersConf ordersConf= new OrdersConf();
        if(StringUtils.isNotBlank(orders.getId())){
            Orders porders=ordersService.get(orders.getId());
            if ("A".equalsIgnoreCase(porders.getOrderClass())) {
                ordersConf.setCategory("0");
            } else {
                if (StringUtils.isBlank(porders.getOrderClass())) {
                    ordersConf.setCategory("2");
                }else{
                    ordersConf.setCategory("1");
                }
            }
            ordersConf.setContinue1(porders.getRepeatIncaditor());
            ordersConf.setValuation(porders.getBillingAttr());
        }
        model.addAttribute("ordersConf",ordersConf);
        model.addAttribute("orders", orders);
        response.setHeader("Pragma","No-cache");
        response.setHeader("Cache-Control","no-cache");
        response.setDateHeader("Expires", 0);
        return "modules/orders/ordersForm";
    }


    /**
     * 保存医嘱
     *
     * @param orders
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = "save")
    @ResponseBody
    public StringData save(Orders orders, Model model) {
        StringData data = new StringData();
        orders.setOrderText(StringUtils.isNotBlank(orders.getOrderDrugText())?orders.getOrderDrugText():StringUtils.isNoneBlank(orders.getOrderEntrustText())?orders.getOrderEntrustText():orders.getOrderClinicText());
        orders.setOrderClass("0".equals(orders.getIsDrug())?"A":orders.getOrderClass());
        Map<String, Object> map = ordersService.saveOrders(orders);
        Integer i = (Integer) map.get("rows");
        if (i > 0) {
            data.setCode("success");
            data.setData("保存医嘱成功");
        } else {
            data.setData("保存医嘱失败");
            data.setCode("error");
        }
        return data;
    }

    /**
     * 删除医嘱与修改医嘱状态
     *
     * @param orders
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = "delete")
    @ResponseBody
    public StringData delete(Orders orders) {
        String message = "";
        String orderStatus = orders.getOrderStatus();
        if ("1".equals(orderStatus)) {
            message = "传输医嘱";
        } else if ("4".equals(orderStatus)) {
            orders.setStopDoct(UserUtils.getUser().getId());
            message = "停止医嘱";
        }/* else if ("5".equals(orderStatus)) {
            message = "作废医嘱";
        }*/ else if ("2".equals(orderStatus)) {
            message = "转抄医嘱";
        } else if ("3".equals(orderStatus)) {
            message = "执行医嘱";
        } else if ("6".equals(orderStatus)) {
            message = "校对医嘱";
        } else if ("7".equals(orderStatus)) {
            message = "护士驳回";
        }else if ("8".equals(orderStatus)) {
            message = "医生停止";
        } else {
            message = "删除医嘱";
        }
        StringData data = new StringData();
        int i = ordersService.delete(orders);
        if (i > 0) {
            data.setCode("success");
            data.setData(message + "成功");
        } else {
            data.setCode("error");
            data.setData(message + "失败");
        }
        return data;
    }

    /**
     * 药品自动补全
     *
     * @param q
     * @param limit
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"autoComplete", ""})
    @ResponseBody
    public List<BaseDto> autoComplete(String q, String limit) {
        if (q != null && !q.equals("")) {
            try {
                q = URLDecoder.decode(q, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return this.ordersService.findListByParam(q, limit, UserUtils.getOrgId());
    }

    /**
     * 查询byId
     *
     * @param id
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"findById", ""})
    @ResponseBody
    public Orders findById(@RequestParam(required = false) String id) {
        Orders entity = null;
        if (StringUtils.isNotBlank(id)) {
            entity = ordersService.get(id);
        }
        if (entity == null) {
            entity = new Orders();
        }
        return entity;
    }

    /**
     * 护士段查询医嘱信息
     *
     * @param orders
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"findNurseOrders", ""})
    public String findNurseOrders(Orders orders, HttpServletRequest request, HttpServletResponse response, Model model) {
        if (orders.getPageFlag() == 0) {//转抄
            orders.setWardCode(UserUtils.getUser().getOrgDept().getId());
            orders.setOrderStatus("");
            orders.setZcFlag("0");
        } else if (orders.getPageFlag() == 1) {//  校对||执行
            //查询病人信息
            PatVisit patVisit = new PatVisit();
            patVisit = patVisitService.findCommonInfo(orders.getPatientId(),orders.getVisitId());
            String orderStatus=orders.getOrderStatus();
            if ("0".equals(orderStatus)) {
                orders.setOrderStatus("2");
            }
            orders.setZcFlag("1");
            model.addAttribute("patVisit", patVisit);
        }
        Page<Orders> page = ordersService.findNurseOrders(new Page<Orders>(request, response), orders);
        model.addAttribute("page", page);
        model.addAttribute("orders", orders);
        if (1 == orders.getPageFlag()) {//校对页面
            return "modules/orders/checkOrdersIndex";
        } else if (0 == orders.getPageFlag()) {//转抄页面
            return "modules/orders/copiedOrdersIndex";
        } else {
            return "";
        }
    }

    /**
     * 护理端-医嘱信息-打印查询
     * @param orders
     * @return
     * @author CTQ
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"findNurseOrdersPrint", ""})
    @ResponseBody
    public StringData findNurseOrdersPrint(Orders orders) {
        StringData stringData = new StringData();
        String printPath=ordersService.findNurseOrdersPrint(orders);
        stringData.setCode("success");
        stringData.setData(printPath);
        return stringData;
    }

    /**
     * 按药品汇总
     *
     * @param orders
     * @param request
     * @param model
     * @return
     * @Index
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"dispIndex", ""})
    public String countByDrug(Orders orders, String type, HttpServletRequest request, HttpServletResponse response, Model model) {
        request.getSession(true).removeAttribute("dispOrderDetails");
        request.getSession(true).setAttribute("dispOrderDetails", "");
        request.getSession(true).removeAttribute("countDrugList");
        request.getSession(true).setAttribute("countDrugList","");
        if (StringUtils.isNotBlank(orders.getWardCode())&&StringUtils.isNotBlank(orders.getTimestamp())) {
            OrgDept orgDept=orgDeptService.get(orders.getWardCode());
            orders.setDeptName(orgDept.getDeptName());
            List<Orders> dispOrderDetails = this.ordersService.findDispOrders(orders.getWardCode(), orders.getVisitNo(), orders.getStorageId(), UserUtils.getOrgId(), orders.getDays(),orders.getBedNo(),orders.getAdministrationes(),orders.getTimestamp());
            if (dispOrderDetails != null && !dispOrderDetails.isEmpty()) {
                Map<String, Object> result = drugDispMidService.saveData(dispOrderDetails);
                Integer rows = (Integer) result.get("rows");
                String dispNo = (String) result.get("dispNo");
                List<Orders> dispOrders =(List<Orders>) result.get("dispOrders");

                if (rows <= dispOrderDetails.size()&&rows>0&&!dispOrders.isEmpty()) {
                    request.getSession(true).setAttribute("dispOrderDetails", dispOrders);
                    orders.setDispNo(dispNo);
                    List<CountDrug> countDrugs = new ArrayList<CountDrug>();
                    List<CountDrug> countDrugList = this.ordersService.countByDrug(orders.getWardCode(), orders.getVisitNo(), orders.getStorageId(), UserUtils.getOrgId(),orders.getBedNo(),orders.getAdministrationes());
                    for (CountDrug countDrug : countDrugList) {
                        double amount = this.countAmount(countDrug.getClinicItemId(), dispOrders);
                        if (amount <= 0) {
                            continue;
                        }
                        countDrug.setDispNo(dispNo);
                        countDrug.setAmount(amount);
                        countDrug.setDays(orders.getDays());
                        countDrugs.add(countDrug);
                    }
                    request.getSession(true).setAttribute("countDrugList", countDrugList);
                    model.addAttribute("countDrugListPage", countDrugs);
                }
            }
        }
        if(orders.getDays()==null){
            orders.setDays(1);
        }

        if(StringUtils.isNotBlank(type)&&type.equals("1")){
            model.addAttribute("storageDepts", this.drugStorageDeptService.findList(new DrugStorageDept()));
         	return "modules/nurse/preSetMedic";
        }else{
            model.addAttribute("storageId",UserUtils.getUser().getOrgDept().getId());
            return "modules/orders/ordersDispIndex";
        }

    }
    /**
     * 遗嘱摆药--摆药详情页面
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"dispOrderDetails", ""})
    public String dispOrderDetails(Orders orders, HttpServletRequest request, HttpServletResponse response, Model model) {
        model.addAttribute("ordersList", request.getSession().getAttribute("dispOrderDetails"));
        return "modules/orders/ordersDispRight";
    }
    /**
     * 医嘱摆药打印
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"dispPrint", ""})
    @ResponseBody
    public StringData dispPrint(Orders orders,HttpServletRequest request, HttpServletResponse response, Model model) {
        StringData stringData = new StringData();
        List<CountDrug> countDrugList = (List<CountDrug>) request.getSession().getAttribute("countDrugList");
        String printPath=this.ordersService.dispPrint(countDrugList,orders.getWardCode());
        stringData.setCode("success");
        stringData.setData(printPath);
        return stringData;
    }



    /**
     * 统计某个药品摆药总数
     *
     * @param clinicItemId
     * @param dispOrderDetails
     * @return
     */
    private double countAmount(String clinicItemId, List<Orders> dispOrderDetails) {
        double amount = 0;
        for (Orders order : dispOrderDetails) {
            String cId = order.getClinicItemId();
            if (clinicItemId.equals(cId)) {
                amount += order.getAmount();
            }
        }
        return amount;
    }
    /**
     * 摆药保存
     * @param dispNo   摆药序号
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"dispSave", ""})
    @ResponseBody
    public String dispSave(String dispNo, String storageId, Integer days, HttpServletRequest request, HttpServletResponse response, Model model) {
        return this.ordersService.dispSave(dispNo, storageId, days);
    }
    //

    /**
     * 遗嘱摆药-已摆药查询  ward_code || name  startDate endDate
     *
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"queryDisped", ""})
    public String queryDisped(DrugDispRec drugDispRec, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<DrugDispRec> page = drugDispRecService.findPage(new Page<DrugDispRec>(request, response), drugDispRec);
        model.addAttribute("page", page);
        if(drugDispRec.getWardCode()!=null&&!"".equals(drugDispRec.getWardCode())){
            drugDispRec.setDeptName(orgDeptService.get(drugDispRec.getWardCode()).getDeptName());
        }
        return "modules/orders/dispedOrdersIndex";
    }
    /**
     *
     * @param inpBillDetail
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"feeOper", ""})
    public String feeOper(InpBillDetail inpBillDetail, HttpServletRequest request, HttpServletResponse response, Model model) {
        PatVisit patVisit = new PatVisit();
        patVisit = patVisitService.findCommonInfo(inpBillDetail.getPatientId(),inpBillDetail.getVisitId());
        patVisit.setId(inpBillDetail.getVisitId());
        patVisit.setPatientId(inpBillDetail.getPatientId());
        model.addAttribute("patVisit", patVisit);
        inpBillDetail.setType("0");
        Page<InpBillDetail> page = inpBillDetailService.findListBy(new Page<InpBillDetail>(request, response), inpBillDetail);
        model.addAttribute("page", page);
        return "modules/orders/feeOper";
    }

    /**
     *
     * @param inpBillDetail
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"feeform", ""})
    public String feeform(InpBillDetail inpBillDetail, HttpServletRequest request, HttpServletResponse response, Model model) {
         return "modules/orders/feeform";
    }


    /**
     *
     * @param inpBillDetail
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"nurseOperFee", ""})
    @ResponseBody
    public StringData nurseOperFee(InpBillDetail inpBillDetail, HttpServletRequest request, HttpServletResponse response, Model model) {
        inpBillDetail.setPriceId(inpBillDetail.getPriceId().substring(0,inpBillDetail.getPriceId().length()-1));
        StringData data = new StringData();
        PatVisit patVisit=patVisitService.get(inpBillDetail.getVisitId());
        inpBillDetail.setWardCode(patVisit.getWardCode());
        inpBillDetail.setDeptStayed(patVisit.getDeptStayed());
        int i = inpBillDetailService.nurseOperFee(inpBillDetail);
        if (i > 0) {
            data.setCode("success");
            data.setData("操作成功");
        } else {
            data.setCode("error");
            data.setData("操作失败");
        }
        return data;
    }


    /**
     *
     * @param q
     * @param limit
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"automaticClinic", ""})
    @ResponseBody
    public List<BaseDto> automaticClinic(String q, String limit) {
        if (q != null && !q.equals("")) {
            try {
                q = URLDecoder.decode(q, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return this.ordersService.automaticClinic(q, limit, UserUtils.getOrgId());
    }

    /**
     *
     * @param
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"confirmDrug", ""})
    public String confirmDrug(InpBillDetail inpBillDetail, HttpServletRequest request, HttpServletResponse response, Model model) {
        inpBillDetail.setType("1");
        Page<InpBillDetail> page = inpBillDetailService.findPage(new Page<InpBillDetail>(request, response), inpBillDetail);
        model.addAttribute("page",page);
        return "modules/orders/confirmDrug";
    }

//

    /**
     * 确认退药
     * @param inpBillDetail
     * @param request
     * @param response
     * @param model
     *
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"doConfirm", ""})
    @ResponseBody
    public StringData doConfirm(InpBillDetail inpBillDetail, HttpServletRequest request, HttpServletResponse response, Model model) {
         StringData data = new StringData();
         int i = inpBillDetailService.doConfirm(inpBillDetail);
         if (i > 0) {
            data.setCode("success");
            data.setData("操作成功");
         } else {
            data.setCode("error");
            data.setData("操作失败");
         }
        return data;
    }

    /**
     * 医嘱打印
     * @param orders
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"printOrders", ""})
    public String printOrders(Orders orders,HttpServletRequest request, HttpServletResponse response, Model model) {
         //todo
         return "modules/orders/printOrders";
    }

    /**
     *
     * @param orders
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"selectCopiedOrders", ""})
    @ResponseBody
    public StringData selectCopiedOrders(Orders orders,HttpServletRequest request, HttpServletResponse response, Model model) {
        StringData stringData=new StringData();
        orders.setWardCode(UserUtils.getUser().getOrgDept().getId());
        orders.setZcFlag("0");
        orders.updateOrgId();
        List<Orders> orderses = ordersService.selectCopiedOrders(orders);
        if(orderses!=null &&orderses.size()>0){
            stringData.setCode("success");
            stringData.setData("<font color=red>您有"+orderses.size()+"条医嘱需要转抄</font>");
        }else{
            stringData.setCode("error");
            stringData.setData("");
        }
        return stringData;
    }


    /**
     * 护士端-查询医嘱瓶签信息
     * @param orders
     * @param model
     * @return
     * @author CTQ
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"findOrdersBottleLabel", ""})
    public String findOrdersBottleLabel(Orders orders,PatVisit patVisit ,Model model) {
        orders.updateOrgId();
        if (StringUtils.isNotBlank(orders.getAdministration())){
            List<String> adm = Lists.newArrayList();
            if (orders.getAdministration().contains(",")){
                String[] strs = orders.getAdministration().split(",");
                for (String str : strs){
                    adm.add(str);
                }
            }else{
                adm.add(orders.getAdministration());
            }
            orders.setAdmList(adm);
        }

        orders.setWardCode(UserUtils.getUser().getOrgDept().getId());
        patVisit.setBedNo(orders.getBedNo());
        patVisit.setWardAdmissionTo(UserUtils.getUser().getOrgDept().getId());
        List<BaseDto> listp = patVisitService.findPatientList(patVisit);
        model.addAttribute("listp",listp);
        model.addAttribute("orders",orders);
        //model.addAttribute("patVisit",patVisit);

        return "modules/orders/ordersBottleLabel";
    }



   @RequiresPermissions("user")
   @RequestMapping(value = {"findOrdersBottle", ""})
  public String findOrdersBottle(Orders orders,Model model) {
     List<Orders> list = ordersService.findOrdersBottleLabel(orders);
       model.addAttribute("list",list);
      return "modules/nurse/inPatVisitInfoOrders";
   }
    /**
     * 护士端-查询医嘱瓶签信息-打印
     * @param orders
     * @return
     * @author CTQ
     */
    @RequiresPermissions("user")
    @RequestMapping(value = {"ordersBottleLabelPrint", ""})
    @ResponseBody
    public StringData ordersBottleLabelPrint(Orders orders){
        orders.updateOrgId();
        StringData stringData = new StringData();
        String printPath = ordersService.findOrdersBottleLabelPrint(orders,UserUtils.getUser());
        stringData.setData(printPath);
        stringData.setCode("success");
        return stringData;
    }
    /**
     *
     * @param id
     * @return
     */
    @RequiresPermissions("user")
    @RequestMapping(value = "saveTreatTemplate")
    @ResponseBody
    public StringData saveTreatTemplate(String id,String fTreatId,String visitId,String patientId,String prescApplyId,Orders orders){
        StringData data=new StringData();
        Map<String, Object> map=ordersService.saveTreatTemplate(id,fTreatId,visitId,patientId,prescApplyId,orders.getList());
        Integer i = (Integer) map.get("rows");
        if(i!=null){
            data.setCode("success");
            data.setData("保存处方成功");
        }else{
            data.setCode("error");
            data.setData("保存处方失败");
        }
        return data;
    }
    /**
     *   医嘱瓶签右侧展示
     * @param
     * @param request
     * @param response
     * @param model
     * @author lizhongyu
     */
    @RequiresPermissions("user")
    @RequestMapping(value ="inPatVisitInfoOrders")
    public String inPatVisitInfoOrders(Orders orders, HttpServletRequest request, HttpServletResponse response, Model model) {
        orders.setWardCode(UserUtils.getUser().getOrgDept().getId());
        List<Orders> list = ordersService.findOrdersBottleLabel(orders);
        model.addAttribute("orders",orders);
        model.addAttribute("list",list);
        return "modules/nurse/inPatVisitInfoOrders";
    }


    /**
     * 医嘱本打印
     *
     * @param Orders
     * @param model
     * @return
     * @author xueliang
     */
    @RequiresPermissions("user")
    @RequestMapping(value = "doctoradviseprint")
    @ResponseBody
    public StringData doctoradviseprint(Orders Orders, Model model, String visitNo) {
        StringData stringData = new StringData();
        String printPath = ordersService.doctoradviseprint(Orders);
        stringData.setCode("success");
        stringData.setData(printPath);
        return stringData;
    }


    @RequiresPermissions("user")
    @RequestMapping(value = {"findByUser", ""})
    @ResponseBody
    public List<BaseDto> findByUser(String category,String continue1,String valuation) {
        return this.ordersService.findByUser(category,continue1,valuation);
    }


}